package accounting.customer.model.service;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import accounting.customer.model.dao.CustomerDao;
import accounting.customer.model.vo.CustomerVO;
import accounting.utils.ListVO;
import accounting.utils.PagingBean;

public class CustomerServiceImpl implements CustomerService{
	private CustomerDao customerDao;
	public CustomerServiceImpl(CustomerDao customerDao) {
		super();
		this.customerDao = customerDao;
	}
	public CustomerDao getCustomerDao(){
		return customerDao;
	}
	@Override
	public void insertCustomer(CustomerVO cus_vo) throws SQLException {
		// TODO Auto-generated method stub
		customerDao.insertCustomerInfo(cus_vo);
		
	}
	@Override
	public List selectCustomer() throws SQLException {
		// TODO Auto-generated method stub
		return customerDao.selectCustomer();
	}
	public ListVO selectCustomerList(int pageNo) throws SQLException{	
		int total=customerDao.selectTotalContent();
		System.out.println("totalContent : "+total);
		PagingBean pagingBean=new PagingBean(total,pageNo);
		ArrayList list=(ArrayList) customerDao.selectCustomerList(pageNo);
		ListVO lvo=new ListVO(list,pagingBean);
		return lvo;
	}
	public CustomerVO selectContent(String no) throws SQLException{
		customerDao.updateCount(Integer.parseInt(no));
		CustomerVO vo=customerDao.selectContent(Integer.parseInt(no));
		return vo;
	}
	@Override
	public void insertNewCustomer(CustomerVO vo) throws SQLException {
		// TODO Auto-generated method stub
		customerDao.insertNewCustomer(vo);
	}
	@Override
	public void updateCustomer(CustomerVO vo) throws SQLException {
		// TODO Auto-generated method stub
		customerDao.updateCustomer(vo);
	}
	@Override
	public List<CustomerVO> selectCustomerCodeList() throws SQLException {
		// TODO Auto-generated method stub
		return customerDao.selectCustomerCodeList();
	}

}
